"use strict"

  export default {
		name:"network_mixin",
        data() {
           return {
              // 网络状态
              isConnect:false,
				description:'网络连接发生问题，请检查网络连接',
           }
        },
        mounted(){
            //检测网络状态
            uni.getNetworkType({
                success:  (res)=>{
                    this.showNetState(res.networkType);
                }
            });
            //监听网络状态变化
            uni.onNetworkStatusChange( (res)=>{
                this.showNetState(res.networkType);
            });
        },
        methods:{
            //显示网络状态
            showNetState(state){
				this.isConnect= state!='none';
				uni.showToast({
					icon:"none",
					title: '网络已' + (this.isConnect ? "连接":"断开"),
				});
				if(this.isConnect) this.refresh()
            },
			refresh(){
				
			}
        },
       watch:{

       }
    };